<%@ page contentType="text/html; charset=utf-8" %>
<%@ include file="/WEB-INF/jsp/includeTaglib.jsp" %>
					<form id="taskPerformSearchForm">
						<div class="globalText" style="padding: 8px;border: solid 1px #999999;margin: 8px;width: auto;" >
							<table class="globalText dbborder" width="100%" border="0" cellpadding="5" cellspacing="5" style="margin: 5px;">
								<tr>
									<td width="5%">地区</td>
									<td>
										<select id="areaId" onchange="findDivision('0',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text)">
											<option value="">--</option>
											<option value="1">东区</option>
											<option value="2">南区</option>
											<option value="3">西区</option>
											<option value="4">北区</option>
										</select>
										<select  id="provinceSelList" onchange="findDivision('1',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text)" >
											<option value="">--</option>
										</select>
										<select  id="citySelList" onchange="findDivision('2',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text)">
											<option value="">--</option>
										</select>
										<input type="hidden" id="adCode" value="" />
									</td>
									
									<td width="5%">项目</td>
									<td>
										<select name="projectCode" id="projectSelectList" >
											<option value="">请选择项目</option>
											<c:forEach var="pl" items="${projectList}" > 
												<option value="${pl.code}">${pl.name}</option> 
 											</c:forEach>
											
											
										</select>
									</td>
								</tr>
								<tr>
									<td align="left" colspan="4" >
										<input  onclick="javascript:searchOpenRate();" type="button" class=" btnStyle" value="提交" />
									</td>
								</tr>
								
							</table>
						</div>
					</form>
						
						
						
<script type="text/javascript">

	$(document).ready(function() { 
		$("#projectSelectList").select2(); 
	});

    function findDivision(depth,code,adname){
    	
    	if(depth==0){
    		var provinceCodes=areaCat[code];
    		$("#citySelList").empty();
	    	$("#provinceSelList").empty();
	    	$("#citySelList").append("<option value='''>--</option>");
	    	$("#provinceSelList").append("<option value='''>--</option>");
    		for(var i=0;i<provinceCodes.length;i++){
    			var province=findProvince(provinceCodes[i]);
    			if(province){
			    	$("#provinceSelList").append("<option value='"+province['code']+"'>"+province['name']+"</option>");
    			}
    		}
    	}else{
    		$.ajax({
 			   type: "POST",
 			   url: "<c:url value='/json/findAdminDivisions.html' />",
 			   data: "adname="+encodeURIComponent(adname)+"&depth="+depth+"&code="+code,
 			   dataType: "json",
 			   success: function(msg){
 				    var sel;
 			    	if(depth==1){
 			    		sel=$("#citySelList")
 			    		$("#citySelList").empty();
 			    		
 			    		$("#citySelList").append("<option value='''>--</option>");
 			    	}else if(depth==2){
 			    	}
 			    	
 			    	sel.empty();
 			    	sel.append("<option value='''>--</option>");
 		    		for(var i=0;i<msg.length;i++){
 		    			sel.append("<option value="+msg[i].id+">"+msg[i].name+"</option>");
 		    		}
 			   }
 			});
    	}
    	
    	
		
	}
    
    var allProvince=new Array();
    <c:forEach var="ad" items="${provinceList}" >
    	allProvince.push({"code":'${ad.code}',"name":'${ad.name}'});
    </c:forEach>
    
    
    var areaCat=${customArea};
    
    function findProvince(code){
    	for(var i=0;i<allProvince.length;i++){
    		if(allProvince[i]['code']==code){
    			return allProvince[i];
    		}
    	}
    }
    
    
    function searchOpenRate(){
    	var url="";
    	
    	if($('#citySelList').val()!=""){
    		url="/report/storeVisitingTrack/reportList/2/"+$('#citySelList').val()+".html";
    	}else if($('#provinceSelList').val()!=""){
    		url="/report/storeVisitingTrack/reportList/1/"+$('#provinceSelList').val()+".html";
    	}else if($('#areaId').val()!=""){
    		url="report/storeVisitingTrack/reportList/6/"+$('#areaId').val()+".html";
    	}else{
    		url="report/taskPerformanceRate/reportList/1.html";
    	}
    	if(url!=""){
    		$('#taskPerformancePage').attr("src",'<c:url value="/" />'+url+"?"+$('#taskPerformSearchForm').serialize());
    	}
    	
    }
    
</script>